<?php

namespace yunj;

use yunj\control\YunjControl;

final class YunjLayui {

    // 系统必须的模块扩展
    private $moduleExtend = [
        'yunj' => '/static/yunj/js/modules/yunj.min',
        'md5' => '/static/yunj/js/modules/md5.min',
        'cookie' => '/static/yunj/js/modules/cookie.min',
        'dropdown' => '/static/yunj/js/modules/dropdown.min',
        'download' => '/static/yunj/js/modules/download.min',
        'button' => '/static/yunj/js/modules/button.min',
        'elemProgress' => '/static/yunj/js/modules/elem-progress.min',
        'loadProgress' => '/static/yunj/js/modules/load-progress.min',
        'tableExport' => '/static/yunj/js/modules/table-export.min',
        'validate' => '/static/yunj/js/modules/validate.min',
        'validateMethods' => '/static/yunj/js/modules/validate-methods.min',
        'YunjField' => '/static/yunj/js/modules/form_field/YunjField.min',
        'YunjTableTemplet' => '/static/yunj/js/modules/table_templet/YunjTableTemplet.min',
        'YunjColsTemplet' => '/static/yunj/js/modules/table_templet/cols/YunjColsTemplet.min',
        'tableToolbar' => '/static/yunj/js/modules/table_templet/table-toolbar.min',
        'col_custom' => '/static/yunj/js/modules/table_templet/cols/custom.min',
    ];

    private static $instance;

    public static function instance() {
        if (!self::$instance instanceof self) {
            self::$instance = new self();
        }
        return self::$instance;
    }

    public function moduleExtend() {
        static $datas;
        if ($datas) return $datas;
        $datas = $this->moduleExtend + YunjControl::instance()->fieldModuleArr + YunjControl::instance()->colsModuleArr;
        $datas = json_encode($datas);
        return $datas;
    }

}